package com.uppfind.framework.core.dao.mybatis.utils;

import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;

/**
 * Created by xuliugen on 2017/6/29.
 */
public class ResultMapsUtils {

    private static SqlSession sqlSession;

    public static ResultMap getResultMap(String id) {
        while (sqlSession == null) {
            try {
                Thread.sleep(10);
                sqlSession = (SqlSession) SpringContextUtil.getApplicationContext().getBean("sqlSessionTemplate");
            } catch (InterruptedException e) {

            }
        }
        return sqlSession.getConfiguration().getResultMap(id);
    }

    public static void setSqlSession(SqlSessionTemplate sqlSession) {
        ResultMapsUtils.sqlSession = sqlSession;
    }
}
